$(function () {
    // 粒子线条背景
    $(document).ready(function () {
        $('.layui-container').particleground({
            dotColor: '#7ec7fd',
            lineColor: '#7ec7fd'
        })
    })

    let layer
    let form
    layui.use(['layer', 'form'], function () {
        layer = layui.layer
        form = layui.form
        // 登录操作
        $(".login-dl").on("submit", function (e) {
            //console.log(1)
            e.preventDefault()
            let data = $(this).serialize()

            $.ajax({
                url: "/api/login",
                type: "POST",
                data: data,
                success: function (res) {
                    if (res.status == 0) {
                        layer.msg(res.message)
                        // 把token保存到本地存储
                        localStorage.setItem('mytoken', res.token)
                        location.href = "/index.html"
                    }
                }
            })
        })
    })
})